#include <bits/stdc++.h>
#include <vector>
using namespace std;

//yuan di hash

class Solution {
public:
    int firstMissingPositive(vector<int>& nums) {
        for(int i=0; i<nums.size(); ++i){
            if(nums[i] > 0 && nums[i] < nums.size() && i!=nums[i]-1){
                int tmp = nums[i];
                nums[i] = nums[tmp-1];
                nums[tmp-1] = tmp;
                --i;
            }
        }
        for(int i=0; i<nums.size(); ++i){
            if(nums[i]!=i+1) return i+1;
        }
        return nums.size();
    }
};

int main(){
    Solution solution;
    vector<int> vec = {-1,4,2,1,9,10};
    int ans = solution.firstMissingPositive(vec);
    return 0;
}